<?php

/**
* エラーチェッククラス
**/
require_once( '../system/Class_DB.php' );

class Class_DAO_OTHER {
		//都道府県
	public static function get_local_array($please_select = NULL){	
		$db = new Class_DB;
		$sql = " select * from M_LOCAL order by local_cd";
		$db->query( $sql);
			
		if ($please_select){
			$data[""] = $please_select;
		}
		while( $row = $db->fetch() ){
			$data[$row["local_cd"]] = $row["local_name"];
		}
		
		return $data;
	}
	
   //商品カテゴリ
	public static function get_categorygood_array($please_select = NULL){	
		$db = new Class_DB;
		$sql = " select * from m_categorygood order by category_cd ";
		$db->query( $sql);
			
		if ($please_select){
			$data[""] = $please_select;
		}
		while( $row = $db->fetch() ){
			$data[$row["category_cd"]] = $row["category_name"];
		}
		
		return $data;
	}
	
	//商品カテゴリ
	public static function get_categorygood_array_item($please_select = NULL){	
		$db = new Class_DB;
		
		if ($please_select){
			$sql2 = " select * from m_category where category_name = '".$please_select."' ";
			$res = $db->query( $sql2);
			$row = $db->fetch();
			$data[$row["id"]] = $please_select;
			
		}
		
		$sql = " select * from m_categorygood order by category_cd ";
		$db->query( $sql);
		while( $row = $db->fetch() ){
			$data[$row["category_cd"]] = $row["category_name"];
		}
		
		return $data;
	}
	
	//$type 1:top page 2:mypage 3:list
	 public static function get_bunner($type, $site = 1) {
	 	$db = new Class_DB;
	 	 $ecjp_ini_plugin_banner_id = 110;
	 	 $sql ="select id,status,animation,interval1 from  d_banner  
	 	 	where banner_type = {$type} and status = 1  and  site= {$site} and  banner_date <= current_timestamp
			order by  banner_date desc ";
			
	 	 $db->query( $sql);
	 	 if ( $row = $db->fetch() ){
	 	 	
	 	 	$id  = $row["id"] ;
	 	 	$sql = "select alt_text,url,target,filename  from  d_image  where func = {$ecjp_ini_plugin_banner_id} and  id = {$id}  order by order_num  ";
	 	 	$db->query( $sql);
	 	 	$data = array();
	 	 	$i = 0;
			while( $row1 = $db->fetch() ){
				$i = $i + 1;
				$data[$i] = $row1;
			}
			$row["images"] = $data;
			
			
			$site_dir = 'site_'. sprintf('%04d', $site)."/files/banner/";
			$row["path"] = $site_dir;
			$row["interval1"] = $row["interval1"] * 1000; 
			
			return $row;
		}else {
			return null;
		}
		
	 }
/* $status説明
	    user_insert =  ユーザ登録
        user_update =  ユーザ更新
        order_over  =  注文完了
     */
   public static function get_email($status,$site_id = 1)
   {
        $db = new Class_DB;
        $sql = sprintf("select * from m_site_email where site_id ='".$db->escape($site_id)."'  and status = '". $db->escape($status) ."'");

        $db->query($sql);
        
		if( $row = $db->fetch() ){
			return $row;
		}
		return null;
               
    }

}

?>